package com.jule.miaozhuapc.service.impl;

import javax.transaction.Transactional;

import com.jule.miaozhuapc.domain.WawaAdvert;
import com.jule.miaozhuapc.dto.AdvertDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jule.miaozhuapc.dao.AdvertDao;
import com.jule.miaozhuapc.dao.PayDao;
import com.jule.miaozhuapc.dao.UserDao;
import com.jule.miaozhuapc.domain.WawaPay;
import com.jule.miaozhuapc.domain.WawaUser;
import com.jule.miaozhuapc.service.AdvertService;
import com.jule.miaozhuapc.service.PayService;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class AdvertServiceImpl implements AdvertService{

    @Autowired
	AdvertDao advertDao;
    @Override
    public List<AdvertDto> findbyType(int type) {

        List<AdvertDto> advertDtos = new ArrayList<>();
        List<WawaAdvert> wawaAdverts = advertDao.findbyType(type);

        if (wawaAdverts != null && wawaAdverts.size() > 0){
            for(WawaAdvert wawaAdvert :wawaAdverts){
                AdvertDto advertDto = new AdvertDto();
                advertDto.setImg(wawaAdvert.getImg());
                advertDto.setUrl(wawaAdvert.getUrl());

                advertDtos.add(advertDto);
            }
        }
        return advertDtos;
    }

}
